package org.example.im.client.console.impl;

import io.netty.channel.Channel;
import org.example.im.bean.protocol.CommandType;
import org.example.im.bean.protocol.request.LeaveGroupRequestPacket;
import org.example.im.client.console.ConsoleCommand;
import org.springframework.stereotype.Component;

import java.util.Scanner;

/**
 * @author dingrui
 * @since 2022/2/12
 * @description
 */
@Component
public class LeaveGroupCommand implements ConsoleCommand {

    @Override
    public CommandType genType() {
        return CommandType.LEAVE_GROUP_REQUEST;
    }

    @Override
    public void exec(Scanner s, Channel c) {
        System.out.println("[C-LeaveGroup] 输入想要退出的群id:");
        String groupId = s.nextLine();
        LeaveGroupRequestPacket request = LeaveGroupRequestPacket.builder().groupId(groupId).build();
        c.writeAndFlush(request);
    }
}
